(function(namespace){
	var bookmark = can.Control({
		defaults : {
			bookmarkTemplate : 'js/app/view/Bookmark.ejs',
			quartersTemplate : 'js/app/view/Quarters.ejs'
		}
	},{
		init : function(element,options){
			var me = this;
			
			this.options.Model.findAll({},function(bookmarks){
				
				
				//TODO separate layout and bookmarks data
				var data = new can.Observe({
					quartersNumber : 5,
					rows : 3,
					columns: 4,
					columnWidth: 137,
					bookmarks : bookmarks,
					bookmarkTemplate : me.options.bookmarkTemplate
				});
				
				$(element).append(can.view(me.options.quartersTemplate,data));
			});
			
			//Sortable & scrolldeck initialization
			$(function(){
				RepositionNav();
				
				$(window).resize(function(){
					RepositionNav();
				});	
				
				new $.scrolldeck({
					slides: '.slide',
					buttons: '#nav li a',
				});

			    $(".quarter").sortable({
			        revert: true,
			    });
			});
			//End of initialization
		}

	});
	
	namespace.Controllers = namespace.Controllers || {};
	namespace.Controllers.Bookmark = bookmark;
})(this);